#include <iostream>
using namespace std;

class Person
{
public:
    Person(string name) : _name(name) {}

    void print() {
        cout << "Person name: " << _name << endl;
    }

private:
    string _name;
};

class IMale
{
public:
    virtual void catchFemale() const = 0;
};

class Boy : public Person,
            public IMale
{
public:
    Boy(string name) : Person(name) {}
    virtual void catchFemale() const {
        cout << "catch girl is happy!" << endl;
    }
};

class Man : public Person,
            public IMale
{
public:
    Man(string name) : Person(name) {}
    virtual void catchFemale() const {
        cout << "catch lady is happy!" << endl;
    }
};

class Things
{
public:
    Things(Person *p) : _person(p) {}
    const Person* getOwner() {return _person;}
private:
    Person *_person;
};

void OwnerSay(Things *pt)
{
    const IMale *pmale = dynamic_cast<const IMale*>(pt->getOwner());
    if (pmale) {
        pmale->catchFemale();
    }
}

int main()
{
    Boy john("john");
    Man bill("bill");

    Things th1(&john);
    Things th2(&bill);

    OwnerSay(&th1);
    OwnerSay(&th2);

    return 0;
}

